<template>
  <div class="steam-ranking">
    <div class="rankingHead">
      <span>steam在线人数今日峰值</span>
    </div>
    <div class="rankingContent">
      <div class="rankingTitle">
        <div style="margin-left: 15px">排名</div>
        <div style="margin-left: 30px">游戏</div>
        <div style="float: right; margin-right: 15px">人数</div>
      </div>
      <div class="rankingItem" v-loading="steamData.loading">
        <steam-item
          v-for="(item, index) in steamData.steamList"
          :key="index"
          :steamItem="item"
        />
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, reactive } from "vue";
import steamItem from "./steamItem.vue";
import { getSteamOnline } from "@/service/youxiaData";
const steamData = reactive({
  steamList: [],
  loading: false,
});
onMounted(() => {
  getSteamList();
});

// 获取榜单数据
const getSteamList = async () => {
  steamData.loading = true;
  const res = await getSteamOnline();
  steamData.steamList = res.data;
  steamData.loading = false;
};
</script>

<style scoped lang="less">
.steam-ranking {
  .rankingHead {
    width: 100%;
    height: 55px;
    line-height: 55px;
    border-bottom: 2px solid #f5f5f5;
    span {
      position: relative;
      font-size: 20px;
      font-weight: bold;
      color: #404040;
      margin-left: 5px;
      float: left;
      z-index: 2;
      &::after {
        content: "";
        margin: auto;
        width: 8px;
        height: 25px;
        background-color: #f76341;
        border-radius: 4px;
        float: left;
        margin: 16px 10px 0 0;
      }
    }
  }
  .rankingContent {
    display: flex;
    flex-direction: column;
    .rankingTitle {
      margin-top: 10px;
      div {
        float: left;
        height: 30px;
        line-height: 30px;
        color: #cccccc;
        font-size: 12px;
      }
    }
    .rankingItem {
      display: flex;
      flex-direction: column;
    }
  }
}
</style>
